<template>
  <div>
    <city-header></city-header>
    <city-search :cities=cities></city-search>
    <city-list :hotCities=hotCities :cities=cities :letter=letter></city-list>
    <city-alphabet :cities=cities @handleLetter="parentsHandleLetter"></city-alphabet>
  </div>
</template>
<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
export default {
  name: 'city',
  data () {
    return {
      hotCities: [],
      cities: {},
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  methods: {
    getCityInfo () {
      this.$http.get('/api/city.json').then(res => {
        console.log(res)
        if (res.data.ret) {
          this.hotCities = res.data.data.hotCities
          this.cities = res.data.data.cities
        }
      })
    },
    parentsHandleLetter (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>
